package com.lyn.solitude.pluginhost.stack

import com.lyn.solitude.entity.Plugin
import java.util.Stack

/**
 *
 * @author longyn 2024/05/22
 * @version 1.0.0
 */
object PluginStack {

    @JvmStatic
    private val pluginStack: Stack<Plugin> = Stack()


    @JvmStatic
    fun push(plugin: Plugin) {
        pluginStack.push(plugin)
    }

    @JvmStatic
    fun peek(): Plugin? {
        try {
            return pluginStack.peek()
        }catch (e:Throwable){
            e.printStackTrace()
        }
        return null
    }

    @JvmStatic
    fun pop(): Plugin? {
        try {
            return pluginStack.pop()
        }catch (e:Throwable){
            e.printStackTrace()
        }
        return null
    }


    @JvmStatic
    fun isEmpty(): Boolean {
        return pluginStack.isEmpty()
    }

    @JvmStatic
    fun size(): Int {
        return pluginStack.size
    }

    @JvmStatic
    fun clear() {
        pluginStack.clear()
    }

}